from rest_framework import mixins
from rest_framework.viewsets import GenericViewSet

from api.toolkit.filters import ToolkitFilter
from api.toolkit.serializers import ToolkitCreateSerializer, ToolkitListSerializer, ToolkitUpdateSerializer
from core.mixin.views import LoverAPIViewMixin
from toolkit.models import Toolkit


class ToolkitApiViewSet(LoverAPIViewMixin, mixins.CreateModelMixin,
                        mixins.UpdateModelMixin,
                        mixins.DestroyModelMixin,
                        mixins.ListModelMixin,
                        GenericViewSet):
    queryset = Toolkit.objects.filter()
    filterset_class = ToolkitFilter

    def get_serializer_class(self):
        if self.action == 'create':
            return ToolkitCreateSerializer
        if self.action == 'partial_update':
            return ToolkitUpdateSerializer
        return ToolkitListSerializer
